﻿// Copyright (c) 2024 刻BITTER
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.


#include <QtSerialPort/qserialport.h>

#include <memory>


namespace scheduler_basic {

    class QtUsTimeoutCounter {
        // TODO:
    };

}  // namespace scheduler_basic

namespace bcup {

    enum class backend_state {
        ok,
        read_timeout,
        write_timeout,

    };

    // 对于阻塞或非阻塞式读写，一个backend 或许只应该提供一种接口，

    /**
     *
     *  @class   QtBackend
     *  @brief   基于QtSerial 实现串口收发
     *
     */
    class QtBackend {
       public:
        using TimeType = uint32_t;

       private:


       public:

            QtBackend() : {}


        // TODO：

        void open() {
        }

        void close() {
        }

        size_t rx_available() const {
        }


        size_t tx_available() const {
        }

        size_t read(uint8_t *dest, size_t count, bool use_frame_end = false, uint8_t frame_end = 0) {

        }

        size_t write(uint8_t* dest, size_t count) {

        }

        backend_state get_state() const {
            
        }

        void set_read_timeout(TimeType t) {

        }

        void set_write_timeout(TimeType t) {

        }


    };
}  // namespace bcup
